package com.yinbw.postgresql.controller;

import com.mybatisplus.common.model.result.ResultBean;
import com.mybatisplus.common.model.param.ParamBean;
import com.mybatisplus.common.page.PageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.extern.slf4j.Slf4j;
import com.yinbw.postgresql.service.ZzService;
import com.yinbw.postgresql.entity.Zz;
import com.mybatisplus.common.controller.BaseController;

import java.util.*;

@Slf4j
@RequestMapping("/zz")
@RestController
public class ZzAction extends BaseController {

    @Autowired
    private ZzService zzService;

    @ApiOperation("")
    @GetMapping("/queryList")
    public List<Zz> queryList() {
        List<Zz> queryList = zzService.queryList();
        return queryList;
    }

    @ApiOperation("")
    @PutMapping("/changeById")
    public ResultBean<Boolean> changeById(@RequestBody Zz zz) {
        Boolean flag = zzService.changeById(zz);
        return ResultBean.createSuccess();
    }

    @ApiOperation("")
    @DeleteMapping("/remove/{id}")
    public ResultBean<Boolean> removeById(@PathVariable Long id) {
        Boolean flag = zzService.removeById(id);
        return ResultBean.createSuccess();
    }

    @ApiOperation("")
    @PostMapping("/saveData")
    public ResultBean<Boolean> saveData(@RequestBody Zz zz) {
        Boolean flag = zzService.saveData(zz);
        return ResultBean.createSuccess();
    }

    @ApiOperation("")
    @PostMapping("/page")
        public ResultBean<PageVo> page(@RequestBody ParamBean<Zz> paramBean) {
        PageVo pageVo = zzService.page(paramBean);
        return ResultBean.createSuccess(pageVo);
    }
}
